package com.example.orderservice.web;

import com.example.orderservice.entity.Order;
import com.example.orderservice.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * program: springcloud-seata
 * description:
 * author: Mr.Yiu
 * create: 2021-05-20 08:51
 **/
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;



    @GetMapping("/list")
    public List<Order> list(){
        return orderService.findOrderList();
    }

    @PostMapping("/create/{userId}/{productId}/{money}/{num}")
    public Map<String,Object> createOrder(
            @PathVariable int userId,
            @PathVariable int productId,
            @PathVariable double money,
            @PathVariable int num){

        return orderService.createOrder(userId, productId, money, num);

    }

    @PostMapping("/createdOrder")
    public int createdOrder(@RequestBody Order order){
        return orderService.createOrder(order);
    }
}
